<%-- 
    Document   : Ejercicio 1
    Description: 
    Created on : 17 de Julio
    Author     : Calderón Chávez Karla Korey
--%>

<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Bean.Tipo"%>
<%@page import="Bean.Usuario"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">


<!DOCTYPE html>
<%
    String context = request.getContextPath();
    HttpSession sesion = request.getSession();
    Usuario login = new Usuario();
    
    List<Tipo> list = new ArrayList<Tipo>();
    
    list = (ArrayList<Tipo>) request.getAttribute("lista");
     String mensaje = (String) request.getAttribute("mensaje");
    if (sesion.getAttribute("login") == null) {
        response.sendRedirect(context + "/ServletLogin");
    } else {
        login = (Usuario) sesion.getAttribute("login");
    }
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
    <head>
        <!--  Created by Artisteer v3.0.0.32906  Base template (without user's data) checked by http://validator.w3.org : "This page is valid XHTML 1.0 Transitional"  -->
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <%=request.getContextPath()%>
        <title>Sistema de Control de Reservaciones CCS</title>
          <link rel="stylesheet" href="<%=request.getContextPath()%>/css/style.css" type="text/css" media="screen" />
<!--        <link href="<%=request.getContextPath()%>/menu_assets/styles.css" rel="stylesheet" type="text/css">-->

         <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/script.js"></script>
        <link rel="stylesheet" href="<%=request.getContextPath()%>/css/jquery.ui.all.css">
        <script src="<%=request.getContextPath()%>/js/jquery-1.9.1.js"></script>
        <script src="<%=request.getContextPath()%>/js//jquery.ui.core.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.widget.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.dialog.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.button.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.mouse.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.draggable.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.position.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.resizable.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.effect.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.effect-fade.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.effect-blind.js"></script>
        <link rel="stylesheet" href="<%=request.getContextPath()%>/css/demos.css">
        <link rel="stylesheet" href="<%=request.getContextPath()%>/css/menu.css">
        <style>


            body { font-size: 62.5%; }
            label, input { display:block; }
            input.text { margin-bottom:12px; width:95%; padding: .4em; }
            fieldset { padding:0; border:0; margin-top:25px; }
            h1 { font-size: 1.2em; margin: .6em 0; }
            div#users-contain { width: 350px; margin: 20px 0; }
            div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 80%; }
            div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
            .ui-dialog .ui-state-error { padding: .3em; }
            .validateTips { border: 1px solid transparent; padding: 0.3em; }
        </style>
        <script>
            $(function() {
		$( "input[type=submit], button" )
			.button()
			.click(function( event ) {
				event.preventDefault();
			});
	});
	(function( $ ) {
		$.widget( "custom.combobox", {

		});
	})( jQuery );

	$(function() {
		$( "#combobox" ).combobox();
		$( "#toggle" ).click(function() {
			$( "#combobox" ).toggle();
		});
	});
	</script>
    </head>
    <body >



        <div id="art-page-background-glare">
            <div id="art-page-background-glare-image">
                <div id="art-main">
                    <div class="art-sheet">

                        <div class="art-sheet-body">
                            <div class="art-header">
                                <div class="art-header-center">
                                    <div class="art-header-png"></div>
                                    <div class="art-header-jpeg"></div>
                                </div>
                                <div class="art-logo">
                                    <h1 id="name-text" class="art-logo-name"><a href="../index.html"></a></h1>
                                    <h2 id="slogan-text" class="art-logo-text"></h2>
                                </div>
                            </div>
                            <div class="art-nav">
                                <div class="l"></div>
                                <div class="r"></div>
                                <ul class="art-menu">
                                </ul>
                            </div>
                            <div class="art-content-layout">
                                <div class="art-content-layout-row">
<!--                                    <div class="art-layout-cell art-sidebar1">-->
                                        <div id='cssmenu'>
                                    <ul>
                                       <li class='active'><a href='<%=context%>index.jsp'><span>Inicio</span></a></li>
                                       <li class='has-sub'><a href='<%=context%>/ControladorDispositivos?accion=Consultar'><span>Equipo</span></a></li>
                                       <li class='has-sub'><a href='#'><span>Aulas</span></a></li>
                                       <li class='has-sub'><a href='#'><span>Reservaciones</span></a></li>
                                       <li class='has-sub'><a href="<%=context%>/ControladorProfesor?accion=Consultar"><span>Profesores</span></a></li>

                                    </ul>
                                    </div>



                                    </div>
                                    <div class="art-layout-cell art-content">
                                        <div class="art-post">
                                            <div class="art-post-body">
                                                <span class="art-button-wrapper" style="margin-left:80%; margin-top:10px;">
                                                    <span class="art-button-l"> </span><span class="art-button-r"> </span>
                                                    <a  class="art-button"  href="<%=context%>/ServletLogin?accion=cerrarSesion">Cerrar Sesión</a>
                                                </span>

                                                <div class="art-post-inner art-article">
                                                    <div class="art-postmetadataheader">

                                                        <h2 class="art-postheader">Registro de equipo</h2>
                                                    </div>
                                                    <div class="art-postcontent">
                                                        
                                                            

                                                            <form name="formulario" action="../../ControladorDispositivos" method="post">
                                                                <%=(mensaje != null ? mensaje : "") + "<br>"%>
                                                            <input type="hidden" name="id" />
                                                            <fieldset>
                                                                <label for="name">Descripción:</label>
                                                                    <input type="text" name="descripcion" id="descripcion" class="text ui-widget-content ui-corner-all" />
                                                                    <label for="name">Modelo:</label>
                                                                    <input type="text" name="modelo" id="modelo" class="text ui-widget-content ui-corner-all" />
                                                                    <label for="name">No. de Serie:</label>
                                                                    <input type="text" name="serial" id="serial" class="text ui-widget-content ui-corner-all" />
                                                                    <label for="name">Tipo:</label>
                                                                    <select id="tipo" name="tipo"  onchange="cambio();">
                                                                            <%for (Tipo disp : list) {%>
                                                                            <option  value="<%=disp.getId()%>"><%=disp.getDescripcion()%></option>
                                                                            <%}%>
                                                                        </select>
                                                                         <input type="hidden" id="id_tipo" name="id_tipo" value=""/>
<!--                                                                    <input type="text" name="tipo" id="tipo" class="text ui-widget-content ui-corner-all" />-->
                                                                    <label for="name">Cantidad:</label>
                                                                    <input type="text" name="cantidad" id="cantidad" class="text ui-widget-content ui-corner-all" />

                                                            </fieldset>
                                                         
                                                               <input type="hidden" name="accion" value="Insertar"/> 
                                                            
                                                            <table align="center"><input type="submit" value="Insertar" onclick="alerta()" name="accion">
                                                            </table>    

                                                            </form>

                                                        
                                                    </div>
                                                    <div class="cleared"></div>
                                                </div>
                                                <div class="cleared"></div>
                                            </div>
                                        </div>
                                        <div class="cleared"></div>
                                    </div>
                                </div>
                            </div>
                            <div class="cleared"></div>
                            <div class="art-footer">
                                <div class="art-footer-t"></div>
                                <div class="art-footer-l"></div>
                                <div class="art-footer-b"></div>
                                <div class="art-footer-r"></div>
                                <div class="art-footer-body">
                                    <div class="art-footer-text">

                                        <p>Universidad Tecnològica Emiliano Zapata Av.Universidad Tecnològica No.1, Col. Palo Escrito, C.P.62760, Emiliano Zapata, Morelos.</p>
                                        <p>Tel.(01777) 368-11-65 Ext.270 jonathanaguilar@utez.edu</p>
                                    </div>
                                    <div class="cleared"></div>
                                </div>
                            </div>
                            <div class="cleared"></div>
                        </div>
                    </div>
                    <div class="cleared"></div>

                </div>
            </div>
        </div>

    </body>
</html>
<script type="text/javascript">
    function cambio(){
        var tipo=document.getElementById("tipo").value;
        document.getElementById("id_tipo").value=tipo;
//        var select=document.getElementsByTagName(tipo).text;
//        alert(tipo);
    }
    function alerta(){
        var cantidad=document.getElementById("id_tipo").value;
        if(cantidad==""){
        alert("Seleccione una opcion de la lista desplegable");
        }else{
        document.formulario.submit();
        }
    }
</script>
